<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script src="js/jquery-2.2.3.min.js"></script>
<script type="text/javascript" src="js/jquery-cookie-1.4.1.js"></script>
<script type="text/javascript" src="js/vue-2.6.11.js"></script>
<script type="text/javascript" src="js/axios-0.19.2.min.js"></script>
<script type="text/javascript" src="js/layer.js"></script>
<script type="text/css" src="js/mobile/need/layer.css"></script>
<script>
    $(function () {
        new Vue({
            data: {},
            methods: {
                getWxLoginInfo() {
                    axios.post("wx/getWxLoginInfo").then((res) => {
                        if (res.data.flag) {
                            // 免密登录处理
                            $.cookie("userId", res.data.data.userId, {path: "/", expires: 7});
                            // 存储到sessionStorage中
                            localStorage.setItem("userId",res.data.data.loginUser.id);
                            localStorage.setItem("username",res.data.data.loginUser.username);
                            debugger;
                            // 跳转到首页
                            location.href = '/home';
                        } else {
                            layer.msg(res.data.message)
                        }
                    })
                }
            },
            created() {
                this.getWxLoginInfo();
            }
        })
    })
</script>
</body>
</html>